package com.yuju.common.util.http;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;

public class Test {

	public static void mainV1(String[] args) {
		HttpWrapper httpWrapper = new HttpWrapper("post", "http", "192.168.31.218", "8080", null);
		// 设置Action
		httpWrapper.setAction("sysLogin.action");
		
		Map<String, Object> headers = new HashMap<String, Object>();
		headers.put("ContentType", "application/json");
		httpWrapper.setHeaders(headers);
		
		Map<String, String> params = new HashMap<String, String>();
		params.put("enterprisecode", "30016");
		params.put("usercode", "18847705655");
		params.put("password", "5e0bdcbddccca4d66d74ba8c1cee1a68");
		// 加入参数
		httpWrapper.addParams(params);
		HttpClientHandler handler = HttpClientHandler.getInstance();
		try {
			handler.execute(httpWrapper, new IHttpClientCallBack() {
				@Override
				public void execute(Object obj) {
					System.out.println(obj.toString());
				}
			});
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		httpWrapper = new HttpWrapper("post", "http", "192.168.31.218", "8080", null);
		// 设置Action
		httpWrapper.setAction("user.action");
		params = new HashMap<String, String>();
		params.put("service", "search");
		params.put("funccode", "MSYS03001");
		params.put("page", "1");
		params.put("rows", "2");
		httpWrapper.addParams(params);
		try {
			handler.execute(httpWrapper, new IHttpClientCallBack() {
				@Override
				public void execute(Object obj) {
					System.out.println(obj.toString());
				}
			});
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		HttpWrapper httpWrapper = new HttpWrapper("post", "http", "t-pmsback.yu500.com", null, null);
		// 设置Action
		httpWrapper.setAction("hotel/selectHotelTown");
		
		Map<String, Object> headers = new HashMap<String, Object>();
		headers.put("Content-Type", "application/json");
		httpWrapper.setHeaders(headers);
		
		/*Map<String, String> params = new HashMap<String, String>();
		params.put("enterprisecode", "30016");
		params.put("usercode", "18847705655");
		params.put("password", "5e0bdcbddccca4d66d74ba8c1cee1a68");
		// 加入参数
		httpWrapper.addParams(params);*/
		JSONObject param = new JSONObject();
		/*param.put("name", "admin123");
		param.put("password", "111111");*/
		param.put("cityName", "太原市");
		httpWrapper.setParam(param.toJSONString());
		HttpClientHandler handler = HttpClientHandler.getInstance();
		try {
			handler.execute(httpWrapper, new IHttpClientCallBack() {
				@Override
				public void execute(Object obj) {
					System.out.println(obj.toString());
				}
			});
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
